import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getExaminationtasksPage',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    category: queryParams.category, //考试分类 id
    examMode: queryParams.examMode, //考试方式 id
    examLevel: queryParams.examLevel, //考试级别 id
    examPlace: queryParams.examPlace, //考试地点 id
    department: queryParams.department, //考试部门 id
    startTime: queryParams.startTime, //考试开始时间
    endTime: queryParams.endTime, //考试结束时间
  }
  return request({
    url: '/getExaminationtasksList',
    method: 'post',
    data: data
  })
}

// 新增
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      title: val.title, //考试名称
      typeId: val.typeId, //考试类型 id
      typeVal: val.typeVal, //考试类型
      levelId: val.levelId, //考试级别 id
      levelVal: val.levelVal, //考试级别
      examModeId: val.examModeId, //考试方式 id
      examMode: val.examMode, //考试方式
      departmentId: val.departmentId, //考试部门 id
      department: val.department, //考试部门
      paperId: val.paperId, //考试试卷 id
      paper: val.paper, //考试试卷
      shiftId: val.shiftId, //考试班组 id
      shift: val.shift, //考试班组
      personnelIds: val.personnelIds, //参加考试人员名单id列表
      personnelNames: val.personnelNames, //参加考试人员名单（格式：部门-姓名）
      personnelNum: val.personnelNum, //参加考试人数
      source: val.source, //考试任务来源 1-培训任务附加 2-独立考试
      trainingtaskId: val.trainingtaskId, //考试任务id，独立考试时为0
      trainingtask: val.trainingtask, //考试任务名称，独立考试时为空值
      frequency: val.frequency, //允许考试次数 0-不限次数
      placeId: val.placeId, //考试地点 id
      place: val.place, //考试地点
      thePic: val.thePic, //考试封面图片
      introduction: val.introduction, //考试简介
      instructions: val.instructions, //考试须知
      startTime: val.startTime, //考试开始时间
      endTime: val.endTime, //考试结束时间
      taskType: val.taskType, //任务类型
    }
  }
  return request({
    url: '/addExaminationtasks',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getExaminationtasksData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      theid: val.theid, //id
      title: val.title, //考试名称
      typeId: val.typeId, //考试类型 id
      typeVal: val.typeVal, //考试类型
      levelId: val.levelId, //考试级别 id
      levelVal: val.levelVal, //考试级别
      examModeId: val.examModeId, //考试方式 id
      examMode: val.examMode, //考试方式
      departmentId: val.departmentId, //考试部门 id
      department: val.department, //考试部门
      paperId: val.paperId, //考试试卷 id
      paper: val.paper, //考试试卷
      shiftId: val.shiftId, //考试班组 id
      shift: val.shift, //考试班组
      personnelIds: val.personnelIds, //参加考试人员名单id列表
      personnelNames: val.personnelNames, //参加考试人员名单（格式：部门-姓名）
      personnelNum: val.personnelNum, //参加考试人数
      source: val.source, //考试任务来源 1-培训任务附加 2-独立考试
      trainingtaskId: val.trainingtaskId, //考试任务id，独立考试时为0
      trainingtask: val.trainingtask, //考试任务名称，独立考试时为空值
      frequency: val.frequency, //允许考试次数 0-不限次数
      placeId: val.placeId, //考试地点 id
      place: val.place, //考试地点
      thePic: val.thePic, //考试封面图片
      introduction: val.introduction, //考试简介
      instructions: val.instructions, //考试须知
      startTime: val.startTime, //考试开始时间
      endTime: val.endTime, //考试结束时间
      taskType: val.taskType, //任务类型
    }
  }
  return request({
    url: '/updateExaminationtasks',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delExaminationtasks',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleExaminationtasks',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getExaminationtasksComboBox',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
  const data = {
    projectContent: {
      theid,
      enable
    }
  }
  return request({
    url: '/changeEnableExaminationtasks',
    method: 'post',
    data: data
  })
}

// 考试班组
export function Examinationteam(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    deptId: queryParams.deptId,
  }
  return request({
    url: '/getShiftList',
    method: 'post',
    data: data
  })
}

// 选择考试试卷下拉
export function getExampapers(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getPaperList',
    method: 'post',
    data: data
  })
}

// 班组名称弹框
export function getCrewpopel(queryParams) {
  const data = {
    theid: queryParams.theid,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getPersonnelListExaminationtasks',
    method: 'post',
    data: data
  })
}

// 发布 
export function getPublish(val) {
  const data = {
    projectContent: {
      theid: val.theid, //id
      reviewerId: val.reviewerId,
      reviewer: val.reviewer,
      reviewTime: val.reviewTime
    }
  }
  return request({
    url: '/toPublishExaminationtasks',
    method: 'post',
    data: data
  })
}
// 取消发布
export function getUnpublish(theid) {
  const data = {
    theid
  }
  return request({
    url: '/unPublishExaminationtasks',
    method: 'post',
    data: data
  })
}